from django.db import models

# Create your models here.


# 种类：
class Kind(models.Model):
    name = models.CharField(max_length=30,verbose_name='种类名')

    class Meta:
        verbose_name = '种类表'
        verbose_name_plural = verbose_name
        db_table = 'tb_kind'

    def __str__(self):
        return self.name


# 图书表：
class Books(models.Model):
    name = models.CharField(max_length=30,verbose_name='图书名')
    price = models.DecimalField(max_digits=5,decimal_places=2,verbose_name='图书价格')
    num = models.IntegerField(verbose_name='图书数量')
    cate = models.ForeignKey(to=Kind,on_delete=models.CASCADE,verbose_name='所属种类')

    class Meta:
        verbose_name = '图书表'
        verbose_name_plural = verbose_name
        db_table = 'tb_book'

    def __str__(self):
        return self.name


class Png(models.Model):
    img = models.CharField(max_length=100,verbose_name='图片')

    class Meta:
        verbose_name = '图片表'
        verbose_name_plural = verbose_name
        db_table = 'tb_png'

    def __str__(self):
        return self.img





